import base64
import json
import os

import re
from io import BytesIO

import lzstring
#
x = lzstring.LZString()
#
# DataQiJson = '''{"p":{"search":{"sq":[{"te":"sunglasses","fi":"PROD"}]},"rows":50,"start":150},"type":"design","la":"en","qi":"1-yMz6VFsC7YkmYonCfWW4heHdfWx/AZUGs3iQqnSsqbg="}'''
#
# # url = (DataQiJson % ('sunglasses', 50, 50 * 2))
#
# JsonLs = x.compressToBase64(DataQiJson)
# JsonLs = x.decompressFromBase64("1-yMz6VFsC7YkmYonCfWW4heHdfWx/AZUGs3iQqnSsqbg=")
# # print(x.decompresFromBase64(QzData))
# # # print(url)
# print(JsonLs)

compressed = x.compressToBase64(u'你好') # 'gbyl9NI='
print("compressed:::",compressed)
print("decompressFromBase64::::",x.decompressFromBase64(compressed)) # '你好'



# st2 = url
# pattern = "KEY.*?(?=(&|$))"
# result = re.search(pattern, st2)
#
# Key1 = result.group().split("-")[0].split("KEY=")[1]
#
#
# Key12 = re.search('[a-zA-Z]', Key1)
# Key122 = re.sub('[a-zA-Z]', "", Key1)
#
# Key1221 = re.sub(pattern, "KEY=" + str(int(Key122)), st2)
# print(Key1221)

# base64Str = ""
# arrays = base64Str.split(",")
#
# image_data = base64.b64decode(arrays[1])
#
# # 将二进制数据封装成文件流
# image_stream = BytesIO(image_data)
#
# print(type(image_stream), image_stream)
